package com.example.reactor.r2dbc.db.factory;

import lombok.RequiredArgsConstructor;
import org.springframework.data.r2dbc.core.R2dbcEntityTemplate;
import org.springframework.data.r2dbc.repository.support.R2dbcRepositoryFactory;

/**
 * R2dbcRepositoryFactory 默认没有注册，暂时跑不通
 *
 * @author zpMeng
 * @since 6/16/2025
 */
//@Repository
@RequiredArgsConstructor
public class DynamicRepositoryFactory {
    private final R2dbcRepositoryFactory factory;
    private final R2dbcEntityTemplate template;

    public <T> T createRepository(Class<T> repoInterface, String tableName) {
        return factory.getRepository(repoInterface, new DynamicRepoImpl(template, tableName));
    }
}
